package com.buaa.hyf.testviewpager;

import android.app.Activity;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by Jeson on 2016/4/19.
 */
public class MyPagerAdapter extends PagerAdapter {


    private List<View> allViews;


    public MyPagerAdapter(List<View> allViews){
        this.allViews = allViews;
    }

    @Override
    public int getCount() {
        return allViews.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
            container.addView(allViews.get(position));  //将所有的东西加到容器里面
        return allViews.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeViewAt(position);

    }
}
